package com.wuliu.web.controller.order;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.wuliu.common.annotation.Log;
import com.wuliu.common.core.controller.BaseController;
import com.wuliu.common.core.domain.AjaxResult;
import com.wuliu.common.enums.BusinessType;
import com.wuliu.system.domain.TspOrderDetail;
import com.wuliu.system.service.ITspOrderDetailService;
import com.wuliu.common.utils.poi.ExcelUtil;
import com.wuliu.common.core.page.TableDataInfo;

/**
 * 托寄物明细Controller
 * 
 * @author realue
 * @date 2023-10-25
 */
@Api(tags = {"托寄物明细"})
@RestController
@RequestMapping("/order/detail")
public class TspOrderDetailController extends BaseController {
    @Resource
    private ITspOrderDetailService tspOrderDetailService;

    /**
     * 查询托寄物明细列表
     */
    @ApiOperation(value = "查询")
    @PreAuthorize("@ss.hasPermi('order:detail:list')")
    @GetMapping("/list")
    public TableDataInfo list(TspOrderDetail tspOrderDetail) {
        startPage();
        List<TspOrderDetail> list = tspOrderDetailService.selectTspOrderDetailList(tspOrderDetail);
        return getDataTable(list);
    }

    /**
     * 导出托寄物明细列表
     */
    @ApiOperation(value = "导出")
    @PreAuthorize("@ss.hasPermi('order:detail:export')")
    @Log(title = "托寄物明细", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TspOrderDetail tspOrderDetail) {
        List<TspOrderDetail> list = tspOrderDetailService.selectTspOrderDetailList(tspOrderDetail);
        ExcelUtil<TspOrderDetail> util = new ExcelUtil<TspOrderDetail>(TspOrderDetail.class);
        util.exportExcel(response, list, "托寄物明细数据");
    }

    /**
     * 获取托寄物明细详细信息
     */
    @ApiOperation(value = "详细")
    @PreAuthorize("@ss.hasPermi('order:detail:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id) {
        return success(tspOrderDetailService.selectTspOrderDetailById(id));
    }

    /**
     * 新增托寄物明细
     */
    @ApiOperation(value = "新增")
    @PreAuthorize("@ss.hasPermi('order:detail:add')")
    @Log(title = "托寄物明细", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TspOrderDetail tspOrderDetail) {
        return toAjax(tspOrderDetailService.insertTspOrderDetail(tspOrderDetail));
    }

    /**
     * 修改托寄物明细
     */
    @ApiOperation(value = "编辑")
    @PreAuthorize("@ss.hasPermi('order:detail:edit')")
    @Log(title = "托寄物明细", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TspOrderDetail tspOrderDetail) {
        return toAjax(tspOrderDetailService.updateTspOrderDetail(tspOrderDetail));
    }

    /**
     * 删除托寄物明细
     */
    @ApiOperation(value = "删除")
    @PreAuthorize("@ss.hasPermi('order:detail:remove')")
    @Log(title = "托寄物明细", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids) {
        return toAjax(tspOrderDetailService.deleteTspOrderDetailByIds(ids));
    }
}
